package cn.tedu.csmall.stock.webapi.quartz;


import cn.tedu.csmall.stock.webapi.utils.RedisBloomUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDateTime;

public class QuartzJob implements Job {
    @Autowired
    private RedisBloomUtils redisBloomUtils;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
       //要执行的任务，例如输出当前时间
//        System.out.println("-------------------------"+LocalDateTime.now()+"-------------------------");
       //定义个向布隆过滤器中要保存的元素
        String[] colors={"red","yellow","green","blue","pink"};
        redisBloomUtils.bfmadd("colorBloom",colors);
        //定义要检查的字符
        String elm1 = "pink";
        String elm2 = "black";
        //输出判断结果
        System.out.println("判断："+elm1+"是否在布隆过滤器中："
                +redisBloomUtils.bfexists("colorBloom",elm1));
        System.out.println("判断："+elm2+"是否在布隆过滤器中："
                +redisBloomUtils.bfexists("colorBloom",elm2));
    }
}
